package com.xuehu.cloud.config;

import org.springframework.cloud.gateway.route.Route;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author guoweia@cslc.com.cn
 * @create 2020/12/9 16:21
 * @desc
 */
@Configuration
public class GateWayConfig {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder){
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        routes.route("", r -> r.path("/mil").uri("http://news.baidu.com/mil")).build();
        routes.route("", r -> r.path("/guoji").uri("http://news.baidu.com/guoji")).build();
        routes.route("", r -> r.path("/guonei").uri("http://news.baidu.com/guonei")).build();
        routes.route("", r -> r.path("/finance").uri("http://news.baidu.com/finance")).build();
        return  routes.build();
    }

}
